local run = 0
capture confirm variable TimeGoingToThisSchool
if !_rc {
	expand 2 if WZBSample, gen(expanded)
	replace WZBSample = 0 if expanded
	drop expanded
	
	local cVar "WZBSample"
	local captionCol1 "Whole UNICEF Sample"
	local captionCol2 "Sampled Children (this Study)"
	local fileNameSuffix "A1"
	
	* Contact
	global contact_cont "TimeGoingToThisSchool NumFriendsOutGroup"
	global contact_bin "FriendsFromOutGroupAtSchool "

	* SES Variables/Demographics
	global demographics "childMale "
	global SES_cont "nHouseholdMembers"
	global SES_bin "childHasSmartphone "

	local variables $contact_cont $contact_bin $demographics $SES_cont $SES_bin
	local run = 1
}

capture confirm variable HowmanyMEMTAsessionsdidyou
if !_rc {
	expand 2 if selectedSchool, gen(expanded)
	replace selectedSchool = 0 if expanded
	drop expanded
	
	local cVar "selectedSchool"
	local captionCol1 "All Teachers (UNICEF Sample)"
	local captionCol2 "Teachers at Sampled Schools (this Study)"
	local fileNameSuffix "A2"
	local notes "Notes: This table shows that teachers in our sample of double-shift schools were statistically indistinguishable from the whole universe of teachers in their responses to questions about the program implemented by Integrated International."
	
	local variables  HowmanyMEMTAsessionsdidyou Num_Doyouthinkthatthesessionsw Num_MoodDidyouobserveanypositiv Num_BehaviorsDidyouobserveanypo Num_ParticipationInClassroomDidy Num_ConfidenceDidyouobserveanyp Num_CooperationDidyouobserveany Num_MotivationToReadDidyouobser
	local run = 1
}

if `run' {

	di "`variables'"

	local nVariables: word count `variables'
	di "`nVariables'"

	qui su `cVar', detail
	if `r(max)' <= 2 {
		mat T = J(`nVariables',4,.)
		local i = 1

		foreach variable of local variables {
		ttest `variable', by(`cVar')
		mat T[`i',1] = r(mu_1)
		mat T[`i',2] = r(mu_2)
		mat T[`i',3] = r(mu_1) - r(mu_2)
		mat T[`i',4] = r(p)
		local i = `i' +1
		}

		su `cVar' if `cVar' == 0
		local nCluster1 = `r(N)'
		su `cVar' if `cVar' == 1
		local nCluster2 = `r(N)'

		mat rownames T = `variables'
	
		frmttable using "2_output/Table`fileNameSuffix'", statmat(T) varlabels replace ///
		ctitle("", "`captionCol1'", "`captionCol2'", Difference, "(p-value)") ///
		addrows("Number of observations", "`nCluster1'", "`nCluster2'") ///
		colwidth(40 15 15 10 10)
	}
}
* Have a nice day!